﻿<html>
<body>
  <h1>System object</h1>
  <p class="note">Methods of this object are not always available to the script - they depend on feature parameters of VM creation.</p>
  <dl>
    <h2>Constants</h2>
    <dt>IS_READONLY</dt>
    <dd>- int, scanFiles callback/attributes, file/dir is readonly.</dd>
    <dt>IS_DIR</dt>
    <dd>- int, scanFiles callback/attributes, file is directory(folder).</dd>
    <dt>IS_HIDDEN</dt>
    <dd>- int, scanFiles callback/attributes, file/dir is marked as hidden.</dd>
    <dt>IS_SYSTEM</dt>
    <dd>- int, scanFiles callback/attributes, file/dir is marked as internal for the system.</dd>
    <dt>MOBILE_OS</dt>
    <dd>- true for the <em>mosciter</em> that is running on mobile platform, false otherwise.</dd>
    <dt>DESKTOP_OS</dt>
    <dd>- true for the <em>sciter</em> running on desktop PC/platform, false otherwise.</dd>
    <dt>OS</dt>
    <dd>- symbol, on Windows it is one of these:
      <ul>
        <li><code>#Windows-98</code></li>
        <li><code>#Windows-98-SE</code></li>
        <li><code>#Windows-ME</code></li>
        <li><code>#Windows-CE</code> - Windows CE or Windows Mobile</li>
        <li><code>#Windows-NT4</code></li>
        <li><code>#Windows-2000</code></li>
        <li><code>#Windows-2003</code></li>
        <li><code>#Windows-XP</code></li>
        <li><code>#Windows-Vista</code></li>
        <li><code>#Windows-7</code></li>
      </ul>
    </dd>
    <dt>PLATFORM</dt>
    <dd>- symbol, one of these:
      <ul>
        <li><code>#Windows</code></li>
        <li><code>#OSX</code></li>
        <li><code>#Linux</code></li>
				
      </ul>
			
    </dd><dt>EOL</dt>
		<dd>- string, platform specific end-of-line sequence, on Windows &quot;\r\n&quot; and on others &quot;\n&quot;.&nbsp;</dd>
    
    <h2>Properties</h2>
    <dt>language</dt>
    <dd>The abbreviated name of the language, ISO Standard 639 names.</dd>
    <dt>country</dt>
    <dd>Country/region name, based on ISO Standard 3166.</dd>
    <dt>ticks</dt>
    <dd>High resolution timer. Return an integer representing the time elapsed since the engine started in milliseconds</dd>
    
    <h2>Methods</h2>
    <dt>scanFiles</dt>
    <dd>
      <p><strong>( </strong><em>path</em>:string [,<em> callback</em>:function]<strong> )</strong> :integer</p>
      <p>Function calls <em>callback</em> function for each entry found in directory defined by the <em>path. Path</em> can contain wildcards like ? or *. Function returns number of entries scanned.</p>
      <p>If callback is ommited then function just returns number of items satisfying path condition. In this form the scan can be used for testing of some file existence as an example.</p>
      <p>Callback function shall accept two parameters:</p>
      <blockquote>
        <p>function <em>callback</em>( <em>filename</em>: string, <em>attributes</em>: integer ): bool</p></blockquote>
      <p>where <em>filename</em> is an name of the file and <em>attributes</em> is an integer - OR-ed combination of IS_*** flags. Callback function shall return <em>true</em> if further scanning needed and <em>false</em> to stop enumeration.</p></dd>
    <dt>home</dt>
    <dd>
      <div><strong>(</strong>[<em>relpath</em>:string]<strong>)</strong> returns: <em>string</em></div>
      <p>Returns home folder of the application - folder where sciter started from. If <em>relpath</em> is some string then it will be appended to the return value. Use this if you need to find fully qualified file name residing in sciter folder or subfolder.</p></dd>
    <dt>path</dt>
    <dd>
      <div><strong>(</strong>system-folder: symbol [,<em>relpath</em>:string]<strong>)</strong> returns: <em>string</em></div>
      <p>Returns path of one of the system folders. <em>system-folder</em> here is one of:</p>
      <ul>
        <li><code>#SYSTEM</code></li>
        <li><code>#SYSTEM_BIN</code></li>
        <li><code>#PROGRAM_FILES</code></li>
        <li><code>#USER_APPDATA</code></li>
        <li><code>#COMMON_APPDATA</code></li>
        <li><code>#USER_DOCUMENTS</code></li>
        <li><code>#COMMON_DOCUMENTS</code></li>
				<li><code>#USER_HOME</code> - user's home directory</li>
				<li><code>#DOWNLOADS</code></li></ul></dd>
    <dt>exec</dt>
    <dd>
      <div><strong>(</strong>exe-path: string [,arg1:string ... argN: string]<strong>)</strong> returns: integer</div>
      <p>Starts executable asynchronously passing optional command line parameters. The method does not wait for executable to complete.</p>
      <p>Retuns 0 if executable has started successfully and C runtime <code>errno</code> variable code otherwise (<b>EACCES</b>, <b>ENOTDIR</b>, etc.).</p>
			</dd><dt>dir</dt>
		<dd><strong>( </strong><em>path</em>:string ,<em> callback</em>:function[, <i>wantStats</i>: true | false]<strong> )</strong> : true | false<p>Extended version of&nbsp;<i>scanFiles</i> function. The callback function accepts three parameters:</p><p><code>function <em>callback</em>( <em>fileName</em>: string, fileType: symbol, fileStats: object )</code> where:</p>
			<ul><li>  <b>filename</b> is name and extension of the file;</li>
				<li><b>fileType</b> is one of <code>#unknown | #file | #dir | #link | #fifo | #socket | #char | #block</code> - type of entry in the directory.</li>
				<li><b>fileStats</b> (if requested) is an object with the fields:<ul id="filestats"><li><b>dev</b> - integer, the numeric identifier of the device containing the file.</li><li><b>ino</b> - integer, the file system specific &quot;Inode&quot; number for the file.</li><li><b>mode</b> - integer, a bit-field describing the file type and mode.</li><li><b>nlink</b> - integer, the number of hard-links that exist for the file.</li><li><b>uid</b> - integer, the numeric user identifier of the user that owns the file (POSIX).</li><li><b>gid</b> - integer, the numeric group identifier of the group that owns the file (POSIX).</li><li><b>rdev</b> - integer, a numeric device identifier if the file is considered &quot;special&quot;.</li><li><b>size</b> - float, the size of the file in bytes.</li><li><b>blksize</b> - integer, the file system block size for i/o operations.</li><li><b>blocks</b> - integer, the number of blocks allocated for this file.</li><li><b>atime</b> - Date, the timestamp indicating the last time this file was accessed.</li><li><b>mtime</b> - Date, the timestamp indicating the last time this file was modified.</li><li><b>ctime</b> - Date, the timestamp indicating the last time the file status was changed.</li><li><b>birthtime</b> - Date, the timestamp indicating the creation time of this file.</li>
						</ul></li>
				</ul>
			</dd><dt>stat<br>sync.stat</dt>
		<dd>( <i>path</i>: string ) : <i>promise</i> or <a href="#fileStats">FileStats</a><p>Asynchronous method that returns promise. Can be used as:</p>
			<pre>System.stat(&quot;d:/test.txt&quot;).then( function(stats) {...} );</pre>Or in asynchronous functions as:
			<pre>async function checkStats() {
   var stats = await System.stat(&quot;d:/test.txt&quot;);
   ...
}</pre></dd>
		<dt>unlink<br>sync.unlink</dt>
		<dd><b>(</b> <i>path</i>: string <b>)</b> : <i>promise</i> (true | error code on failure)<p>Asynchronously or synchronously removes a file or symbolic link.</p>
			</dd><dt>rmdir<br>sync.rmdir</dt>
		<dd><b>(</b> <i>path</i>: string <b>)</b> : <i>promise</i> (true | error code on failure)<p>Removes directory (a.k.a. folder). Directory must be empty. The function calls <a href="http://man7.org/linux/man-pages/man2/rmdir.2.html">rmdir</a>.&nbsp;</p>
			</dd><dt>mkdir<br>sync.mkdir</dt>
		<dd><b>(</b> <i>path</i>: string <b>)&nbsp;</b>: <i>promise</i> (true | error code on failure)<p>Creates directory (a.k.a. folder). The function calls <code>mkdir</code>.&nbsp;</p></dd>
  <dt>rename<br>sync.rename</dt>
		<dd><b>(</b> <i>oldPath</i>: string, <i>newPath</i>: string <b>)&nbsp;</b>: <i>promise</i> (true | error code on failure)
    <p>Asynchronously rename file at <i>oldPath</i> to the pathname provided as <i>newPath</i>. In the case that newPath already exists, it will be overwritten. If there is a directory at newPath, an error will be raised instead.</p></dd>
		<dt>copyFile<br>sync.copyFile</dt>
		<dd><b>(</b> &nbsp;<i>srcPath</i>: string, <i>dstPath</i>: &nbsp;string [,<i>#no-overwrite</i>] <b>)&nbsp;</b>: <i>promise</i> (true | error code on failure)<p>Asynchronously copies <i>src</i> to <i>dst</i>. By default, <i>dst</i> is overwritten if it already exists. Sciter makes no guarantees about the atomicity of the copy operation. If an error occurs after the destination file has been opened for writing, Sciter will attempt to remove the destination. If #<i>no-overwrite</i> parameter is provided the operation will fail if something is on dstPath already.&nbsp;</p></dd>
  <dt>utimes<br>sync.utimes</dt>
		<dd><b>(</b> <i>path</i>: string,  <i>atime</i>: Date, <i>mtime</i>: Date <b>)&nbsp;</b>: <i>promise</i> (true | error code on failure)<p>Change the file system timestamps of the object referenced by path.&nbsp;</p>
			</dd>
  <dt>chmod<br>sync.chmod</dt>
		<dd><b>(</b> <i>path</i>: string,  <i></i>mode: integer <b>)&nbsp;</b>: <i>promise</i> (true | error code on failure)<p>Changes file mode bits. The function calls <a href="http://man7.org/linux/man-pages/man2/chmod.2.html">chmod</a>&nbsp;system function.</p>
			</dd>
<dt>watch</dt>
		<dd><b>(</b> <i>path</i>: string <b>)&nbsp;</b>: <i>FileMonitor</i> <p>Creates FileMonitor object that will receive change notifications on a file or folder content. The only public method of FileMonitor is <code>close()</code> - stop monitoring and dispose the monitor.&nbsp;The FileMonitor instance supports change and rename events:</p><pre>var watcher = null;  
if( watcher ) 
    watcher.close();
var path = ...;
// create file monitor and subscribe to events:
that.watcher = System.watch(path)
          &lt;&lt; event change (path) { ... change detected ... } 
          &lt;&lt; event rename (path) { ... change detected ... };</pre></dd>
  </dl>
</body>
</html>